Micron Document
`:top
`!Self-testing code`! is software that incorporates built-in tests (see `F33f`_`[test-first development`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Test-first_development]`_`f).`:cite-ref-1[`F5bf`_`[1`#cite-note-1]`_`f]`:cite-ref-2[`F5bf`_`[2`#cite-note-2]`_`f]

`F33f`_`[Perl`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Perl]`_`f packages will run their self tests when they are installed using `F33f`_`[CPAN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=CPAN]`_`f. This ensures that they run successfully in the local environment. (There is also a testing community that tests new packages and updated packages on many different platforms.)

In `F33f`_`[Java`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Java_(programming)]`_`f, to execute a `F33f`_`[unit test`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Unit_test]`_`f from the `F33f`_`[command line`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Command_line]`_`f, a `F33f`_`[class`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Class_(computer_science)]`_`f can have methods like the following.

`B100`F9d9// Executing <code>main</code> runs the unit test.`f`b
`B100`F9d9public static void main(String[] args) {`f`b
`B100`F9d9 test();`f`b
`B100`F9d9}`f`b
`B100`F9d9`f`b
`B100`F9d9static void test() {`f`b
`B100`F9d9 assert foo == bar;`f`b
`B100`F9d9}`f`b

To invoke a full `F33f`_`[system test`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=System_test]`_`f, a class can incorporate a method call.

`B100`F9d9public static void main(String[] args) {`f`b
`B100`F9d9 test();`f`b
`B100`F9d9 TestSuite.test(); // invokes full system test`f`b
`B100`F9d9}`f`b

In addition, Java has some Jupiter API libraries for self-testing code. assert can be used in various ways such as assert equals, which checks if the given variable is equal to the value given.

`B100`F9d9@Test`f`b
`B100`F9d9void checkplayer() {`f`b
`B100`F9d9 Board board = new Board(10);`f`b
`B100`F9d9 board.addplayer(1);`f`b
`B100`F9d9 int check = board.getCurrentPlayer(1);`f`b
`B100`F9d9 assertEquals(1, check);`f`b
`B100`F9d9`f`b
`B100`F9d9 }`f`b

>>Contents

• `F0af`_`[See also`#see-also]`_`f
• `F0af`_`[References`#references]`_`f

-─

>>See also

• `F33f`_`[Software development`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Software_development]`_`f
• `F33f`_`[Extreme programming`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Extreme_programming]`_`f

>>References

`:cite-note-1`!1.`! `F0af`_`[↑`#cite-ref-1]`_`f "Self-testing infrastructure-as-code". `*OpenCredo`*. Retrieved 2022-12-05.
`:cite-note-2`!2.`! `F0af`_`[↑`#cite-ref-2]`_`f "Self Testing Code". `*martinfowler.com`*. Retrieved 2022-12-05.

`c`F0af`_`[↑ Back to top`#top]`_`f`a